#pragma once

#include "processor.h"
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iostream>

#define __debug__

#ifdef __debug__
#define MAX_MEM 0x10000
#endif

#ifndef MAX_MEM
#ifdef __linux__
#define MAX_MEM 0x1000000
#else
#define MAX_MEM 0x800000
#endif
#endif

#ifndef qword
#define qword unsigned long long
#define dword unsigned int
#define word unsigned short
#define byte unsigned char
#define real4 float
#define real8 double
#endif

struct Table
{
    qword length : 56;
    word descript;
    qword base;
};

void init();
qword AddrTrans(qword v_addr);
template <class T>
void putMem(qword v_addr, T data);
template <class T>
T getMem(qword v_addr);
void input(qword address);
void output(qword address);
void write_gdt(word target, qword address);
void mount();
void umount();
void file_read();
void file_write();